<?php
namespace app\manage\model;
use think\Db;

class Game extends Base
{
    public function gameNotice(){
        $select = Db::name('ViewGameManage')->field("game_id, game_name")->select();
        return $select;
    }

    public function gameIdName(){
        $gameSelect = Db::name('ViewGameManage')->field("game_id, game_name")->select();
        $gameIdName = [];
        foreach($gameSelect as $k=>$v){
            $gameIdName[$v['game_id']] = $v['game_name'];
        }
        return $gameIdName;
    }

    public function gameClient($gameServer, $gamePublish, $gamePlatform, $gameClient){
        if($gameServer || $gamePublish || $gamePlatform || $gameClient){
            $where = [];
            $gameServer && $where['app_type_id'] = $gameServer;
            $gamePublish && $where['app_publish_type_id'] = $gamePublish;
            $gamePlatform && $where['app_platform_type_id'] = $gamePlatform;
            $gameClient && $where['app_client_type_id'] = $gameClient;
            $gameArr = Db::name('ViewGameManage')->where($where)->column('game_id');
            if(count($gameArr)){
                $gameStr = implode(',', $gameArr);
                return " && game_id in ({$gameStr})";
            }else{
                return ' && 1=0';
            }
        }else{
            return '';
        }
    }
}